home *** CD-ROM | disk | FTP | other *** search
/ SCI Games E3 2005 Press Kit (USA) / SCI Games E3 2005 Press Kit (USA).bin / runme_mac.swf / scripts / __Packages / mx / controls / streamingmedia / PlayerNetStream.as < prev    next >
Text File  |  2005-05-05  |  3KB  |  112 lines

  1. class mx.controls.streamingmedia.PlayerNetStream extends NetStream
  2. {
  3.    function PlayerNetStream(nc, aPlayer)
  4.    {
  5.       super(nc);
  6.       this.setPlayer(aPlayer);
  7.    }
  8.    function getPlayer()
  9.    {
  10.       return this._player;
  11.    }
  12.    function get player()
  13.    {
  14.       return this.getPlayer();
  15.    }
  16.    function setPlayer(aPlayer)
  17.    {
  18.       this._player = aPlayer;
  19.    }
  20.    function set player(aPlayer)
  21.    {
  22.       this.setPlayer(aPlayer);
  23.    }
  24.    function pause(shouldPause)
  25.    {
  26.       super.pause(shouldPause);
  27.    }
  28.    function setBufferTime(time)
  29.    {
  30.       super.setBufferTime(time);
  31.    }
  32.    function play(name, st, len, reset)
  33.    {
  34.       super.play(name,st,len,reset);
  35.    }
  36.    function seek(offset)
  37.    {
  38.       super.seek(offset);
  39.    }
  40.    function close()
  41.    {
  42.       super.close();
  43.    }
  44.    function attachAudio(theMicrophone)
  45.    {
  46.       super.attachAudio(theMicrophone);
  47.    }
  48.    function attachVideo(theCamera, snapshotMilliseconds)
  49.    {
  50.       super.attachVideo(theCamera,snapshotMilliseconds);
  51.    }
  52.    function onStatus(info)
  53.    {
  54.       var _loc2_ = this.getPlayer();
  55.       switch(info.code)
  56.       {
  57.          case "NetStream.Buffer.Full":
  58.             break;
  59.          case "NetStream.Play.Start":
  60.             this.detectedFirstBuffer = false;
  61.             clearInterval(this.initId);
  62.             this.checkSizeInterval = 10;
  63.             this.initId = setInterval(this,"detect",this.checkSizeInterval);
  64.             break;
  65.          case "NetStream.Pause.Notify":
  66.             break;
  67.          case "NetStream.Play.Stop":
  68.             clearInterval(this.initId);
  69.             _loc2_.playStopped();
  70.             break;
  71.          case "NetStream.Play.Failed":
  72.          case "NetStream.Play.StreamNotFound":
  73.             var _loc3_ = undefined;
  74.             _loc3_ = "Error playing URL: " + info.description;
  75.             _loc2_.logError(_loc3_);
  76.             break;
  77.          case "NetStream.Seek.Notify":
  78.             _loc2_.setSeeking(false);
  79.       }
  80.    }
  81.    function detect()
  82.    {
  83.       var _loc2_ = this.getPlayer();
  84.       if(!this.detectedFirstBuffer && _loc2_.isSizeSet())
  85.       {
  86.          this.detectedFirstBuffer = true;
  87.          _loc2_.bufferIsFull();
  88.       }
  89.       if(_loc2_.isSizeChange())
  90.       {
  91.          _loc2_.resizeVideo();
  92.       }
  93.       clearInterval(this.initId);
  94.       this.checkSizeInterval *= 2;
  95.       this.initId = setInterval(this,"detect",this.checkSizeInterval);
  96.    }
  97.    function onMetaData(info)
  98.    {
  99.       var _loc2_ = this.getPlayer();
  100.       if(_loc2_ instanceof mx.controls.streamingmedia.FLVPlayer)
  101.       {
  102.          var _loc3_ = _loc2_;
  103.          _loc3_.setTotalTime(info.duration);
  104.       }
  105.       else if(_loc2_ instanceof mx.controls.streamingmedia.RTMPPlayer)
  106.       {
  107.          var _loc4_ = _loc2_;
  108.          _loc4_.setTotalTime(info.duration);
  109.       }
  110.    }
  111. }
  112.